package org.example.demo1_danyi.one;

import java.sql.Connection;

public class LoginManager implements LoginInterface {
    private final LoginDisplay loginDisplay;
    private final LoginVerifier loginVerifier;
    private final ConnectionProvider connectionProvider;

    public LoginManager(LoginDisplay loginDisplay, LoginVerifier loginVerifier, ConnectionProvider connectionProvider) {
        this.loginDisplay = loginDisplay;
        this.loginVerifier = loginVerifier;
        this.connectionProvider = connectionProvider;
    }

    @Override
    public void initialize() {
        // 初始化逻辑，可能包括设置登录显示、验证器和连接提供者
    }

    @Override
    public void display() {
        loginDisplay.display();
    }

    @Override
    public boolean verify(String username, String password) {
        return loginVerifier.verify(username, password);
    }

    @Override
    public Connection getConnection() {
        return connectionProvider.getConnection();
    }
}
